<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3.组件的嵌套</title>
    <!--  引入Vue  -->
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <!--  准备好一个容器  -->
    <div id="root">

    </div>
</body>

<script type="text/javascript">
    const student = Vue.extend({
        //extend里不能写el配置项,所有的组件被vm管理,由vm决定服务于哪个容器
        // el:"#root",
        template: `
          <div>
            <h2>学生姓名:{{ studentName }}</h2>
            <h2>学生年龄:{{ age }}</h2>
          </div>
        `,
        data() {
            return {
                studentName: "小明",
                age: "18"
            }
        }
    })

    //第一步:创建school组件
    const school = Vue.extend({
        //extend里不能写el配置项,所有的组件被vm管理,由vm决定服务于哪个容器
        // el:"#root",
        template: `
          <div>
            <h2>学校名称:{{ schoolName }}</h2>
            <h2>学校地址:{{ address }}</h2>
            <student></student>
          </div>
        `,
        data() {
            return {
                schoolName: "尚硅谷",
                address: "北京"
            }
        },
        components: {
            student
        }
    })

    const hello = Vue.extend({
        template: `
          <div>
            <h2>你好啊{{ msg }}</h2>
          </div>
        `,
        data() {
            return {
                msg: "hello"
            }
        }
    })

    const app = Vue.extend({
        template: `
          <div>
            <hello></hello>
            <school></school>
          </div>
        `,
        components: {
            school,
            hello
        }
    })


    new Vue({
        el: "#root",
        template: `
          <app></app>
        `,
        components: {
            app
        }
    })

</script>
</html>